//
//  GYHomeAdViewModel.m
//  GYDemo
//
//  Created by Mrzhang on 2018/3/30.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "GYHomeAdViewModel.h"
#import "Head.h"
@implementation GYHomeAdViewModel
-(NSMutableArray *)addArr
{
    if (!_addArr) {
        _addArr=[[NSMutableArray alloc] init];
    }
    return _addArr;
}
-(NSMutableArray *)marketArr
{
    if (!_marketArr) {
        _marketArr=[[NSMutableArray alloc] init];
    }
    return _marketArr;
}
-(instancetype)init
{
    if (self = [super init]) {
        //添加接口特殊处理
        [[InterfaceManager shareInterface].specialInterfaces addObject:@"homePageBanner"];
    }
    return self;
}

-(void)requestAd:(NSMutableDictionary *)para
{
    @WeakSelf;
    NSString *interface = @"homePageBanner";
    
    [[InterfaceManager shareInterface]requetInterface:interface withParameter:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        NSArray *datalist = infoModel.data;
        
        if ([datalist isKindOfClass:[NSArray class]]) {
            NSMutableArray *arr=[[NSMutableArray alloc] init];;
            for (NSDictionary *dic in datalist) {
                GYAdModel *model = [GYAdModel yy_modelWithJSON:dic];
                [arr addObject:model];
            }
            [selfp setAddArr:arr];
            
        }
    }];
}
-(void)requestMarketAd:(NSMutableDictionary *)para
{
    @WeakSelf;
    NSString *interface = @"homePageBanner";
    
    [[InterfaceManager shareInterface]requetInterface:interface withParameter:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        NSArray *datalist = infoModel.data;
        
        if ([datalist isKindOfClass:[NSArray class]]) {
            NSMutableArray *arr=[[NSMutableArray alloc] init];;
            for (NSDictionary *dic in datalist) {
                GYAdModel *model = [GYAdModel yy_modelWithJSON:dic];
                [arr addObject:model];
            }
            [selfp setMarketArr:arr];
            
        }
    }];
}

@end
